import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:yt_devops/components/app_bar/app_bar_widget.dart';
import 'package:yt_devops/components/app_permission/permission_widget.dart';
import 'package:yt_devops/components/gaps.dart';
import 'package:yt_devops/components/log_utils.dart';
import 'package:yt_devops/components/yt_button.dart';
import 'package:yt_devops/components/yt_text_style.dart';
import 'package:yt_devops/components/my_gesture_detector.dart';
import 'package:yt_devops/pages/site/site_setting/site_setting_base_info/widgets/item_widget.dart';
import 'package:yt_devops/resources/str_res_keys.dart';
import 'package:yt_devops/styles/styles.dart';
import 'package:yt_devops/utils/constants/permission_page_constant.dart';
import '../../../../components/network_image_load/load_image.dart';
import 'site_setting_param_set_controller.dart';

class SiteSettingParamSetPage extends GetView<SiteSettingParamSetController> {
  const SiteSettingParamSetPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder<SiteSettingParamSetController>(
      builder: (controller) => Stack(
        children: [
          Scaffold(
            backgroundColor: Colour.backgroundColor,
            appBar: AppBarWidget.withRightActions(ResKey.parameterSets.tr),
            body: Column(
              children: [
                 Container(
            margin: const EdgeInsets.only(top: 10,left: 16,right: 16),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(8),
              color: Colors.white,
            ),
            clipBehavior: Clip.hardEdge,
            child:Column(children: [
                    // Container(
                    //   height: 10,
                    //   color: Colour.backgroundColor,
                    // ),
                    // ItemWidget(
                    //     ResKey.operationTime.tr,
                    //     controller.runTimeController,
                    //     hintString: ResKey.pleSelect.tr,
                    //     isCanEdit: false,
                    //     isShowRight: true,
                    //     clickCallBack: (){
                    //         controller.chooseTime();
                    //     },
                    // ),
                  PermissionWidget(
                      permissionStringList: const [
                        PermissionConstant.homeSiteManageSettingParameterSettingMonetaryUnit
                      ],
                      child:ItemWidget(
                      ResKey.currencyUnit.tr,
                      controller.currencyUnitController,
                      hintString: ResKey.pleSelect.tr,
                      isCanEdit: false,
                      titleFont: 16,
                      isShowRight: controller.isCanSetUnit,
                      inputTextWidth: 80,
                      isShowDivider: false,
                      clickCallBack: () {
                        if(controller.isCanSetUnit){
                          controller.chooseCurrency(context);
                        }
                      },
                    )),
                    Container(
                      height: 0.5,
                      color: Colors.white,
                      child: Container(
                        height: 0.5,
                        margin: EdgeInsets.only(left: 16.w, right: 16.w),
                        color: Colour.dividerColor,
                      ),
                    ),
                  PermissionWidget(
                      permissionStringList: const [
                        PermissionConstant.homeSiteManageSettingParameterSettingAlarmPush
                      ],
                      child:Container(
                      color: Colors.white,
                      padding: EdgeInsets.fromLTRB(16.w, 0, 16.w, 0),
                      height: 50,
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: [
                          Container(
                            // width: 80,
                            child: Text(ResKey.alarmPush.tr,
                                style: ytTextStyle(
                                    fontSize: 16,
                                    fontWeight: FontWeight.normal)),
                          ),
                          GestureDetector(
                              behavior: HitTestBehavior.opaque,
                              onTap: () {
                                controller.isShowIntroduce = true;
                                controller.update();
                              },
                              child: Container(
                                padding: const EdgeInsets.all(4),
                                child: const LoadImage(
                                  '',
                                  holderImg: 'assets/images/icon_introduce',
                                  width: 16,
                                  height: 16,
                                ),
                              )),
                          const Spacer(),
                          CupertinoSwitch(
                              activeColor: Colour.primaryColor,
                              value: controller.isOpen,
                              onChanged:controller.isCanChangePush? (isOpen) {
                                Log.d('isOpen==$isOpen');

                                controller.setAlarmPush(isOpen);
                                // controller.update();
                              }:null)
                        ],
                      ),
                    )),
                  ]),
                ),
                // Align(
                //   alignment: Alignment.bottomCenter,
                //   child: Container(
                //     color: Colour.white,
                //     margin: const EdgeInsets.only(top: 0),
                //     padding:
                //         EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.h),
                //     child: PermissionWidget(
                //       permissionStringList: const [
                //         PermissionConstant.homeSiteManageSettingParameterSettingSave
                //       ],
                //       child: SafeArea(
                //           child: YtButton(
                //         enabled: true,
                //         color: Colour.primaryColor,
                //         text: ResKey.save.tr,
                //         onPress: () => controller.setParam(),
                //       )),
                //     ),
                //   ),
                // ),
              ],
            ),
          ),
          Visibility(
              visible: controller.isShowIntroduce,
              child: MyGestureDetector(
                onTap: () {
                  controller.isShowIntroduce = false;
                  controller.update();
                },
                child: SizedBox(
                  // color: Colors.black.withOpacity(0.5),
                  width: ScreenUtil().screenWidth,
                  height: ScreenUtil().screenHeight,
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Container(
                        margin: EdgeInsets.only(
                            top: ScreenUtil().statusBarHeight +
                                44 +
                                50 +
                                10 +
                                50,
                            left: controller.leftMargin - 20,
                            right: 37),
                        // color: Colors.red,
                        // height: 100,
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Row(
                              children: [
                                Container(
                                  margin:
                                      const EdgeInsets.only(left: 23, top: 2),
                                  child: const LoadImage(
                                    '',
                                    holderImg:
                                        'assets/images/arrow_up_triangle',
                                    width: 14,
                                    height: 6,
                                  ),
                                ),
                              ],
                            ),
                            Container(
                              padding: const EdgeInsets.all(16),
                              decoration: BoxDecoration(
                                borderRadius:
                                    const BorderRadius.all(Radius.circular(8)),
                                color: Colour.black1AColor.withOpacity(0.95),
                              ),
                              child: Text(
                                ResKey.alarmPushIntroduce.tr,
                                style: ytTextStyle(
                                    color: Colors.white,
                                    height: 1.5,
                                    fontSize: 14),
                              ),
                            )
                          ],
                        ),
                      )
                    ],
                  ),
                ),
              ))
        ],
      ),
    );
  }
}
